<?php
$this->breadcrumbs = array(
    'MLM System',
    'Serial Products' => array('list'),
    'List',
);

$this->menu = array(
		array('label'=>'Aktivasi', 'url'=>'activate'),
		);


//action create
/*
if (Yii::app()->user->administrator_group_type == 'superuser') {
    array_push( $this->menu,
		array('label' => 'Generate Serial Upgrade', 'url' => array('create'))
		
		);
}
*/

//action activate
//if($this->action_activate == 1) {
//    array_push($this->menu, array('label' => 'Serial Products Activate', 'url' => array('activate')));
//}

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('sys-serial-products-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>
<?php if (Yii::app()->user->hasFlash('success')): ?>
    <div class="alert alert_grey">
        <img height="24" width="24" src="<?php echo Yii::app()->params['backendUrl']; ?>/images/icons/small/grey/success.png">
        <?php echo Yii::app()->user->getFlash('success'); ?>
    </div>
<?php endif; ?>
<?php if (Yii::app()->user->hasFlash('error')): ?>
    <div class="alert alert_grey">
        <img height="24" width="24" src="<?php echo Yii::app()->params['backendUrl']; ?>/images/icons/small/grey/alert_2.png">
        <?php echo Yii::app()->user->getFlash('error'); ?>
    </div>
<?php endif; ?>
<div class="flat_area grid_16">
    <h2>List of Serial Products</h2>
</div>
<div class="box grid_16 round_all">
    <h2 class="box_head grad_colour round_all">Advanced Search</h2>
    <a href="#" class="grabber">&nbsp;</a>
    <a href="#" class="toggle toggle_closed">&nbsp;</a>
    <div class="toggle_container" style="display:none;">
        <?php
        $this->renderPartial('_search', array(
            'model' => $model,
        ));
        ?>
    </div>
</div>
<!-- search-form -->
<?php
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'sys-serial-products-grid',
    'dataProvider' => $model->search(),
    'filter' => $model,
    'columns' => array(
        array(
            'header' => 'No.',
            'value' => '$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)."."',
            'htmlOptions' => array('style' => 'text-align:center;'),
        ),
        array(
            'name' => 'serial_products_id',
            'value' => '$data->serial_products_id',
            'htmlOptions' => array('style' => 'text-align:center;'),
        ),
        array(
            'name' => 'serial_products_pin',
            'value' => '$data->serial_products_pin',
            'htmlOptions' => array('style' => 'text-align:center;'),
        ),
        array(
            'name' => 'serial_products_active_datetime',
            'value' => '$data->serial_products_active_datetime',
            'htmlOptions' => array('style' => 'text-align:center;'),
        ),

       array(
            'name' => 'serial_products_is_active',
            'type' => 'image',
            'value' => '($data->serial_products_is_active == 1 ? Yii::app()->request->baseUrl . "/images/icon/b_ok.png" : Yii::app()->request->baseUrl . "/images/icon/b_notok.png")',
            'filter' => CHtml::activeDropDownList($model, 'serial_products_is_active', array('' => '', '1' => 'Active', '0' => 'InActive')),
            'htmlOptions' => array('style' => 'text-align:center;'),
        ),


        array(
            'name' => 'serial_products_is_used',
            'type' => 'image',
            'value' => '($data->serial_products_is_used == 1 ? Yii::app()->request->baseUrl . "/images/icon/b_ok.png" : Yii::app()->request->baseUrl . "/images/icon/b_notok.png")',
            'filter' => CHtml::activeDropDownList($model, 'serial_products_is_used', array('' => '', '1' => 'Used', '0' => 'Unused')),
            'htmlOptions' => array('style' => 'text-align:center;'),
        ),
         array(
            'header' => 'User',
            'value' => 'function_lib::get_network_mid($data->rel_serial_products_to_serial_product_user->serial_products_user_network_id)',
            'htmlOptions' => array('style' => 'text-align:center;'),
        ),
             
        array(
            'header' => 'Date of use',
            'value' => '$data->rel_serial_products_to_serial_product_user->serial_products_user_datetime',
            'htmlOptions' => array('style' => 'text-align:center;'),
        ),
        array(
            'header' => 'Action',
            'class' => 'CButtonColumn',
            'template' => '{view}',
            'buttons' => array(
                'view' => array(
                    'imageUrl' => Yii::app()->request->baseUrl . '/images/icon/adm_detail_navy.png',
                ),
            ),
        ),
    ),
    'selectableRows' => 2,
    'selectionChanged' => 'userClicks',
    'pager' => array(
        'cssFile' => Yii::app()->params['backendUrl'] . '/css/style-pager.css',
        'header' => '',
        'firstPageLabel' => 'First',
        'prevPageLabel' => 'Previous',
        'nextPageLabel' => 'Next',
        'lastPageLabel' => 'Last',
    ),
    'cssFile' => Yii::app()->params['backendUrl'] . '/css/style-gridview.css',
    'loadingCssClass' => '',
));
?>
<script>
    var id = 0;
    function userClicks(target_id) {
        id = $.fn.yiiGridView.getSelection(target_id);
    }
</script>
